#include <windows.h>
#include "resource.h"

#define USER_BUTTON_ID 777


BOOL InsertButton(HWND hwnd, UINT uCmdId, int nSize);

BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_INITDIALOG:
		InsertButton(GetDlgItem(hwnd, IDC_EDIT1),  USER_BUTTON_ID, 18);
		return TRUE;

	case WM_COMMAND:
		
		switch(LOWORD(wParam))
		{
		case IDOK: case IDCANCEL:
			EndDialog(hwnd, 0);
			return TRUE;

		case USER_BUTTON_ID:
			SetDlgItemText(hwnd, IDC_EDIT1, "Edit button pressed");
			return TRUE;
		}
		
		return FALSE;

	case WM_CLOSE:
		EndDialog(hwnd, 0);
		return TRUE;

	}
	return FALSE;
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
	return DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, DlgProc);
}